package yf.mall.entity;


import com.sun.org.apache.xpath.internal.operations.Bool;
import lombok.Setter;
import lombok.Getter;
import java.io.Serializable;
import java.util.Date;

import java.math.BigDecimal;

/**
 * 活动实体
 * 表名 mall_act
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Sun May 24 14:16:14 CST 2020
 */
@Setter
@Getter
public class MallActEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    //
    private Long id;
        //活动名称
    private String name;
        //产品ID
    private Long goodsId;
        //绑定产品ID
    private Long bindGoodsId;
        //绑定数量
    private Integer bindGoodsQuantity;
        //规格id
    private Integer skuId;
        //开始时间
    private Date start;
        //起止时间
    Date[] starts;
        //结束时间
    private Date end;
        //起止时间
    Date[] ends;
        //不可购买级别
    private String level;
        //限购数量
    private Integer number;
        //是否可以转货
    private Integer transfer;
        //是否可以发货
    private Integer delivery;
        //必需积分
    private BigDecimal point;
        //最多使用购物券
    private BigDecimal maxVoucher;
        //最多使用优惠券
    private BigDecimal maxCoupon;
        //积分奖励
    private String pointReward;
        //ENUM-是否立即返利:"是-1","否-0"
    private Integer pointType;
        //优惠券奖励
    private String couponReward;
        //ENUM-是否立即返利:"是-1","否-0"
    private Integer couponType;
        //购物券奖励
    private String voucherReward;
        //ENUM-是否立即返利:"是-1","否-0"
    private Integer voucherType;
        //现金券奖励
    private String cashReward;
        //ENUM-是否立即返利:"是-1","否-0"
    private Integer cashType;
        //区域奖励省_市_县
    private String areaReward;
        //ENUM-是否立即返利:"是-1","否-0"
    private Integer areaType;
        //管理费
    private String managerReward;
        //ENUM-是否立即返利:"是-1","否-0"
    private Integer managerType;
        //活动库存
    private Integer stock;
        //ENUM-状态:"OPEN-打开","CLOSED-关闭"
    private Integer status;

    public MallActEntity(){

    }

    //产品名字
    private String goodsName;

    public Boolean getOpen(){
        Date today = new Date();
        if(start ==null||stock==null||status==null)return false;
        //打开状态  库存充足  时间范围内
        if(status==0&&stock>0&&today.after(start)&&today.before(end)){
            return true;
        }
        return false;
    }

}
